home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 55.0 KB | 1,754 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1990-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: Report.lib
- #
- # Version: 2.1.4
- #
- # Description: Tasks for reporting to the VU notebook; timing.
- #
- # Contains:
- # ROpenTest()
- # RCloseTest()
- # RResult()
- # RAddResult()
- # RStatus()
- # RError()
- # RIncomplete()
- # RXStatus()
- # RXError()
- # RXIncomplete()
- # RDumpState()
- # RPushVerbosity()
- # RPopVerbosity()
- # RPrint()
- # R_Indent() (internal task)
- # R_NestIn() (internal task)
- # R_NestOut() (internal task)
- # R_BeVerbose() (internal task)
- # _takeScreenShot() (internal task)
- # midstr()
- # substr()
- # list_to_str()
- # str_to_list()
- # timed_out()
- # get_end_time()
- # timer()
- # time_list()
- # time_cmp()
- # time_neg()
- # time_add()
- # time_sub()
- # time_str()
- # GetCheckSums()
- # ComputerAidedSE()
- # rSetCAidedSE()
- #
- # History:
- # Date: By: Changes:
- # 08/02/90 Alan Liu Creation
- # 03/04/92 Jason Marsh Incorporated v_level for use with Clouseau.lib.
- # 05/15/92 Jason Marsh Created summaries, rResult, rAddStatus, CAidedSE, etc.
- # 02/22/94 SBR Reformatted according to standards; R_BeVerbose mod
- # 06/29/94 SBR get_end_time mod
- # 07/07/94 SBR rewrote get_end_time mod for speed
- # 09/04/95 SBR updated header for Radar 1273927
- # 09/27/96 BRL/MSO/SBR Updated copyright header
- # Use SPEC exception handling method (ExceptionHandling.lib)
- # 01/21/97 SBR Deleted older exception code and comments.
- #
- #########################################################################
- #########################################################################
-
- Libraries "VUAid.tool",
- "ExceptionHandling.lib";
-
-
- #########################################################################
- # task ROpenTest(name, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report the beginning of a test.
- # Parameters: name: string to log
- # v_level: logs according to RBeVerbose
- # Returns: Nothing
- # Examples: ROpenTest("Close Window tests");
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- # 06/30/93 SBR clear gAddResult
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task ROpenTest(name, v_level:=1)
- begin
- global r_error_stack;
- global r_error_count;
- global r_passed_count;
- global r_incomplete_count;
-
- global gAddResult := {};
-
- if isUndefined(global r_test_stack)
- begin
- r_test_stack := {};
- R_NestIn();
- global r_error_stack := {};
- global r_error_count := 0;
- global r_passed_count := 0;
- global r_incomplete_count := 0;
- end;
-
- save_trace := trace(false);
-
- r_test_stack := insert({name, _Match([time])}, 1, r_test_stack);
-
- if r_error_stack <> {}
- r_error_stack := replace({r_error_count + r_error_stack[1][1],
- r_passed_count + r_error_stack[1][2],
- r_incomplete_count + r_error_stack[1][3]}, 1, r_error_stack);
-
- r_error_stack := insert({0,0,0}, 1, r_error_stack);
- r_error_count := 0;
- r_passed_count := 0;
- r_incomplete_count := 0;
-
- if R_BeVerbose(v_level)
- begin
- R_Indent(v_level);
- println "Begin {name}";
- end;
- R_NestIn();
-
- trace(save_trace);
- end;
-
-
- #########################################################################
- # task RCloseTest(v_level, summary)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report the finishing of a test.
- # Parameters: v_level: logs according to RBeVerbose
- # summary: print a result summary for this block
- # Returns: Nothing
- # Examples: RCloseTest();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task RCloseTest(v_level:=1, summary := false)
- begin
- global r_test_stack, r_error_stack;
- global r_error_count, r_passed_count, r_incomplete_count;
-
- save_trace := trace(false);
-
- test_failed := r_error_count + r_error_stack[1][1];
- test_passed := r_passed_count + r_error_stack[1][2];
- test_incomplete := r_incomplete_count + r_error_stack[1][3];
-
- r_error_stack := remove(1, r_error_stack);
- if r_error_stack <> {}
- r_error_stack := replace({test_failed + r_error_stack[1][1],
- test_passed + r_error_stack[1][2],
- test_incomplete + r_error_stack[1][3]}, 1, r_error_stack);
-
- test := r_test_stack[1];
- r_test_stack := remove(1, r_test_stack);
-
- name := test[1];
- gap := time_str(time_sub(test[2], _Match([time])));
-
- R_NestOut();
- if R_BeVerbose(v_level)
- begin
- if test_failed = 0
- begin
- temp:= "no";
- if test_incomplete <> 0
- begin
- print "•Inc•";
- R_Indent(v_level - 1);
- end;
- else R_Indent(v_level);
- end;
- else begin
- print "•Failed•";
- temp := "{test_failed}";
- R_Indent(v_level - 2);
- end;
- end;
-
- total := test_passed + test_failed;
- println "End {name}: {temp} Errors out of {total} tests ({gap})";
-
- if (r_test_stack = {})
- begin
- R_NestOut();
- R_NestOut();
- end;
-
- if (r_test_stack = {} or summary)
- begin
- println;
- R_Indent(v_level); println "Summary of ", name, ":";
- R_Indent(v_level); println "∂t", total + test_incomplete, " tests run";
- R_Indent(v_level); println "∂t", test_passed, " tests passed";
- R_Indent(v_level); println "∂t", test_failed, " tests failed";
- R_Indent(v_level); println "∂t", test_incomplete, " tests incomplete";
- R_Indent(v_level); println "∂t", "execution time: ", gap;
- println;
- end;
-
- r_error_count := 0;
- r_passed_count := 0;
- r_incomplete_count := 0;
-
- trace(save_trace);
- end;
-
-
-
- #########################################################################
- # task RResult(tResult, testName, expected, actual, takeScrShot, CAidedSE, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report the result of a test. This is the primary
- # communication the script has with the log. Update
- # the test summary. If expected <> actual report them.
- # If takeScrShot is true, do so.
- # Parameters: tResult: true and 'pass' for passed
- # false and 'fail' for error
- # 'incomplete' for incomplete
- # testName: the string to log
- # expected: expected value for a test
- # actual: actual value for a test.
- # takeScrShot: if true, do the routine to take a screen shot.
- # CAidedSE: Print out the result in testN format, instead of errors
- # v_level: logs according to RBeVerbose
- # Returns: Nothing
- # Examples: rResult(actual = expected,"balloon for {testName}", expected, actual);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/92 Jason Marsh Created
- #########################################################################
- task RResult(tResult := "pass", testName := "", expected:= undefined, actual:= undefined, takeScrShot:= false, CAidedSE:= false, v_level:= 2)
- begin
- if IsUndefined(global gCAidedSEEnabled)
- gCAidedSEEnabled := false;
-
- if gCAidedSEEnabled
- return ComputerAidedSE(CAidedSE);
-
- if typeOf(tResult) <> 'string'
- if tResult
- tResult := "pass";
- else tResult := "fail";
-
- if tResult = "incomplete"
- begin
- if IsUndefined(global r_incomplete_count)
- r_incomplete_count := 1;
- else r_incomplete_count := r_incomplete_count +1;
- RIncomplete("Incomplete: " + testName);
- if takeScrShot
- _takeScreenShot();
- end;
- else if (tResult = "pass")
- begin
- if IsUndefined(global r_passed_count)
- r_passed_count := 1;
- else r_passed_count := r_passed_count +1;
- RStatus("Verified: " + testName);
- end;
- else begin
- if IsUndefined(global r_error_count)
- r_error_count := 1;
- else r_error_count := r_error_count +1;
- RError("Failed: " + testName);
- if (not isUndefined(expected) or not isUndefined(actual)) and R_BeVerbose(3)
- begin
- RPrint (" -" , 2, 3);
- if not isUndefined(expected)
- print " expected: ", expected, " ";
- if not isUndefined(actual)
- print " actual: ", actual;
- println;
- end;
- if takeScrShot
- _takeScreenShot();
- end;
-
- if isUndefined(global gAddResult)
- gAddResult := {};
- for i:= 1 to card gAddResult
- begin
- temp := gAddResult[i];
- if R_BeVerbose(3)
- if typeOf(temp) = 'list'
- begin
- RPrint (" -" , 2, 3);
- for each j in temp
- print j;
- println;
- end;
- else RPrint(" - {temp}", 2, 8, true);
- end;
-
- gAddResult := {};
- end;
-
-
- #########################################################################
- # task RAddResult(str, expected, actual)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Add to the result stack of a test, to be printed below
- # the RResult statement. If expected <> actual, print out
- # this information as well.
- # Parameters: str: the str to log
- # expected: the expected value for a test
- # actual: the actual value of a test
- # Returns: Nothing
- # Examples: RAddResult("Verified: all radiobuttons in correct state.");
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/92 Jason Marsh Created
- #########################################################################
- task RAddResult(str := "", expected:= undefined, actual:= undefined)
- begin
- if isUndefined(global gAddResult)
- gAddResult:= {};
-
- if str <> ""
- gAddResult := gAddResult + {str};
-
- if (not isUndefined(expected) or not isUndefined(actual))
- begin
- EAPrint := {};
- if not isUndefined(expected)
- EAPrint := {" expected: ", expected, " "};
- if not isUndefined(actual)
- EAPrint := EAPrint + {" actual: ", actual};
- gAddResult := gAddResult + {EAPrint};
- end;
-
- return true;
- end;
-
-
- #########################################################################
- # task RStatus(str, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report the status of a test.
- # Parameters: str: the str to log
- # v_level: logs according to RBeVerbose
- # Returns: This ALWAYS returns true, enabling it to be used in a
- # 'return' statement with ease and elegance.
- # Examples: if (select_descriptor([menuitem t:"Control Panels" m:1]) <> error)
- # return RStatus("open_control_panel: successful");
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 05/15/92 Jason Marsh Created
- # 04/10/93 SBR Changed RPrint call to use auto-cr parameter
- # 02/19/94 SBR If v_level = -1 send output to RAddResult
- #########################################################################
- task RStatus(str, v_level:= 2)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level))
- RPrint(": {str}", v_level, 2, true);
- else if v_level = -1
- RAddResult(str);
-
- trace(save_trace);
- return true; #no error
- end;
-
- #########################################################################
- # task RError(str, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report a VU-level error in a test.
- # Parameters: str: the str to log
- # v_level: logs according to RBeVerbose
- # Returns: This ALWAYS returns false, enabling it to be used in a
- # 'return' statement with ease and elegance.
- # Examples: if (error) return RError("this_task: didn't work",,450, 451);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 05/15/92 Jason Marsh Created
- # 04/10/93 SBR Changed RPrint call to use auto-cr parameter
- # 02/19/94 SBR If v_level = -1 send output to RAddResult
- #########################################################################
- task RError(str, v_level:= 1)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level)) begin
- print "•E•";
- RPrint("• {str}", v_level, 7, true);
- end;
- else if v_level = -1
- RAddResult("•E• {str}");
-
- trace(save_trace);
- return false; #error
- end;
-
-
- #########################################################################
- # task RIncomplete(str, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report an incomplete result in a test.
- # Parameters: str: the str to log
- # v_level: logs according to RBeVerbose
- # Returns: This ALWAYS returns false, enabling it to be used in a
- # 'return' statement with ease and elegance.
- # Examples: if (error) return RIncomplete("this_task: didn't complete");
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 05/15/92 Jason Marsh Created
- # 04/10/93 SBR Changed RPrint call to use auto-cr parameter
- # 02/19/94 SBR If v_level = -1 send output to RAddResult
- #########################################################################
- task RIncomplete(str, v_level := 1)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level))
- begin
- print "•I•";
- RPrint("! {str}", v_level, 7, true);
- end;
- else if v_level = -1
- RAddResult("•I• {str}");
-
- trace(save_trace);
- return false; #error
- end;
-
-
- #########################################################################
- # task RXStatus(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report the status of a test. This only takes care of
- # proper indentation, etc. It should be used with a
- # println statement. These are neccesary because VU
- # does not easily pass [descriptor] and list[] information
- # to tasks.
- # Parameters: v_level: logs according to RBeVerbose
- # Returns: Returns according to RBeVerbose.
- # Examples: if RXStatus(v_level) println "type_keys: typing ", key_list;
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/92 Jason Marsh Created
- #########################################################################
- task RXStatus(v_level := 2)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level))
- begin
- R_Indent(v_level);
- print ": ";
- retVal := true;
- end;
- else retVal := false;
-
- trace(save_trace);
- return retVal;
- end;
-
-
- #########################################################################
- # task RXError(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report a VU-level error in a test. This only takes care of
- # proper indentation, etc. It should be used with a
- # println statement. These are neccesary because VU
- # does not easily pass [descriptor] and list[] information
- # to tasks.
- # Parameters: v_level: logs according to RBeVerbose
- # Returns: Returns according to RBeVerbose.
- # Examples: if RXError(v_level) println "select_descriptor: Unable to find '",itemDesc,"'";
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/92 Jason Marsh Created
- #########################################################################
- task RXError(v_level:=1)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level))
- begin
- print "•E•";
- R_Indent(v_level);
- print "• ";
- retVal := true;
- end;
- else retVal := false;
-
- trace(save_trace);
- return retVal;
- end;
-
-
- #########################################################################
- # task RXIncomplete(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Report an incomplete result in a test. This only takes care of
- # proper indentation, etc. It should be used with a
- # println statement. These are neccesary because VU
- # does not easily pass [descriptor] and list[] information
- # to tasks.
- # Parameters: v_level: logs according to RBeVerbose
- # Returns: Returns according to RBeVerbose.
- # Examples: if RXIncomplete(v_level) println "select_descriptor: Unable to find '",itemDesc,"'";
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/92 Jason Marsh Created
- #########################################################################
- task RXIncomplete(v_level:=1)
- begin
- save_trace := trace(false);
-
- if (R_BeVerbose(v_level))
- begin
- print "•I•";
- R_Indent(v_level);
- print "! ";
- retVal := true;
- end;
- else retVal := false;
-
- trace(save_trace);
- return retVal; #error
- end;
-
-
- #########################################################################
- # task RDumpState(desc_type, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Show general information about the state of the target
- # machine. We show the current application, the frontmost
- # window, and current menus.
- # Parameters: desc_type: List available descriptors on the target of
- # this type. Can be any VU descriptor type,
- # such as 'button'.
- # v_level: logs according to RBeVerbose
- # Returns: Returns according to RBeVerbose.
- # Examples: RDumpState('menuItem');
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task RDumpState(desc_type := '', v_level:=5)
- begin
- save_trace := trace(false);
-
- try begin
- # many raw matches happen in this section
- # they're all covered by the above try statement
- if (R_BeVerbose(v_level))
- begin
- if desc_type
- begin
- dList := 'UNKNOWN';
- if desc_type = 'menu' ; #Do nothing
- else if desc_type = 'menuItem' match [menuItem t:$dList];
- else if desc_type = 'button' match [button t:$dList];
- else if desc_type = 'window' match [window t:$dList];
- else if desc_type = 'radioButton' match [radioButton t:$dList];
- else if desc_type = 'checkBox' match [checkBox t:$dList];
- else if desc_type = 'popUp' match [popUp t:$dList];
- else if desc_type = 'screen' dList := match [screen];
- else if desc_type = 'scrollBar' match [scrollBar t:$dList];
- else RError("RDumpState: I don't know what a ∂"{desc_type}∂" is.", v_level);
- RXError(v_level);
- println "RDumpState: Available {desc_type}s: ", dList;
- RXError(v_level);
- print " ";
- end;
- else begin
- RXError(v_level);
- print "RDumpState: ";
- end;
- println "Application: ", match [application];
- RXError(v_level);
- println " Front window: ", match [window o:1];
- match [menu t:$dList];
- RXError(v_level);
- println " Available menus: ", dList;
- retVal := true;
- end;
- else
- retVal := false;
- end;
- catch theError
- begin
- trace(save_trace);
- ExceptionDispatcher(theError,,{"RDumpState() match section", {desc_type, v_level}});
- end;
-
- trace(save_trace);
- return retVal;
- end;
-
-
- #########################################################################
- # task RPushVerbosity(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Set the global verbosity. This is used in a stack
- # format with RPopVerbosity().
- # Parameters: desc_type: List available descriptors on the target of
- # this type. Can be any VU descriptor type,
- # such as 'button'.
- # v_level: 0; #no output except for Not-Tested-List
- # 1; #only Begin/End tests, Errors, Not-Tested-List and summaries
- # 2; #run-time output, without specifying multiple verifications
- # 3; #run-time output, with multiple verifications
- # 4; #scripter's debugging-level output
- # 5; #Clouseau-libs level debugging-output
- # Returns: Nothing.
- # Examples: RPushVerbosity(4);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- #########################################################################
- task RPushVerbosity(v_level := 2)
- begin
- global r_verbosity, r_verbosity_stack;
-
- if isUndefined(r_verbosity)
- r_verbosity := 1;
- if isUndefined(r_verbosity_stack)
- r_verbosity_stack := {};
-
- r_verbosity_stack := insert(r_verbosity, 1, r_verbosity_stack);
- r_verbosity := v_level;
- end;
-
- #########################################################################
- # task RPopVerbosity()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Revert to the previous verbosity setting. Popping
- # an empty stack sets the verbosity to 1.
- # Parameters: none
- # Returns: Nothing.
- # Examples: RPopVerbosity();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- #########################################################################
- task RPopVerbosity()
- begin
- global r_verbosity, r_verbosity_stack;
-
- if isUndefined(r_verbosity_stack)
- r_verbosity_stack := {};
-
- if (card r_verbosity_stack) > 0
- begin
- r_verbosity := r_verbosity_stack[1];
- r_verbosity_stack := remove(1, r_verbosity_stack);
- end;
- else r_verbosity := 1;
- end;
-
- #########################################################################
- # task RPrint(str, v_level, nest, auto_cr, word_wrap, tabSize)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Print a string out, using the current indent, and
- # wrapping if longer than word_wrap characters.
- # Parameters: str: string to print to log
- # v_level: only used to determine indentation.
- # nest: specifies the extra indentation for lines
- # after the first line.
- # auto_cr: true to add carriage return
- # word_wrap: Attempt to do a smart word wrap. The only
- # recognized whitespace character is a space.
- # If true but not integer, defaults to 100.
- # tabSize: number of spaces for a tab
- # Returns: Nothing.
- # Examples: RPrint(logString, v_level, 4, true);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/2/90 Alan Liu Creation
- # 04/11/92 SBR removed '†' code, put auto_cr before word_wrap
- # 04/11/92 SBR Changed word_wrap to integer, added tabSize
- #########################################################################
- task RPrint(str, v_level:= 2, nest := 0, auto_cr := false,
- word_wrap := 100, tabSize := 4)
- begin
- global r_nesting; if isUndefined(r_nesting) r_nesting := 0;
-
- strLength := card str;
-
- if word_wrap #for compatibility with old word_wrap
- if (typeOf(word_wrap) <> integer or word_wrap = 1)
- begin
- word_wrap := 100; #for compatibility with old word_wrap
- maxLineLength := word_wrap - tabs * r_nesting;
- end;
- else maxLineLength := 1000;
- done := false;
- currentPosition := 1;
- first_line := true;
- while not done
- begin
- R_Indent(v_level);
- if not first_line
- for i := 1 to nest print " ";
- if (word_wrap and (currentPosition + maxLineLength <= strLength))
- begin
- blank_position := currentPosition + maxLineLength - 1;
- if blank_position > strLength
- blank_position := strLength;
- while str[blank_position] <> ' ' and blank_position > currentPosition
- blank_position := blank_position - 1;
- if (blank_position > currentPosition)
- begin
- print midstr(str, currentPosition, blank_position - currentPosition);
- currentPosition := blank_position + 1; (*Skip the blank*)
- end;
- else begin
- print midstr(str, currentPosition, maxLineLength);
- currentPosition := currentPosition + maxLineLength;
- end;
- end;
- else begin
- if currentPosition = 1 #print a short line fast
- print str;
- else #print the rest of a wrapped line
- print midstr(str, currentPosition, maxLineLength);
- currentPosition := currentPosition + maxLineLength;
- end;
-
- if currentPosition <= strLength
- println;
- else done := true;
-
- if first_line
- begin
- first_line := false;
- maxLineLength := maxLineLength - nest;
- end;
- end;
- if auto_cr
- println;
- end;
-
- #########################################################################
- ######### Internal Tasks #########
- #########################################################################
-
- #########################################################################
- # task R_Indent(v_level)
- # Description: Indent, based on the current level of nesting, or if
- # v_level passed, according to v_level requested.
- # Parameters: v_level: Amount to indent
- # Returns: Nothing
- # History:
- # ??? ??? Created
- #########################################################################
- task R_Indent(v_level := "")
- begin
- global r_nesting; if isUndefined(r_nesting) r_nesting := 0;
- if not (v_level = "") # if v_level passed, and it is 2
- temp := r_nesting + v_level - 1; # indent another time
-
- for i := 1 to temp
- print "∂t";
- end;
-
- #########################################################################
- # task R_NestIn()
- # Description: Increase the level of nesting.
- # Parameters: None
- # Returns: Nothing
- # History:
- # ??? ??? Created
- #########################################################################
- task R_NestIn()
- begin
- global r_nesting;
-
- if isUndefined(r_nesting)
- r_nesting := 0;
-
- r_nesting := r_nesting + 1;
- end;
-
- #########################################################################
- # task R_NestOut()
- # Description: Decrease the level of nesting.
- # Parameters: None
- # Returns: Nothing
- # History:
- # ??? ??? Created
- #########################################################################
- task R_NestOut()
- begin
- global r_nesting;
-
- if isUndefined(r_nesting)
- r_nesting := 0;
-
- r_nesting := r_nesting - 1;
- if (r_nesting < 0)
- r_nesting := 0;
- end;
-
- #########################################################################
- # task R_BeVerbose(v_level)
- # Description: Determine whether printing should occur, given the
- # current verbosity setting compared to the v_level of
- # this specific message.
- # Parameters: v_level: Verbosity of this message. The higher the
- # number, the less likely the global verbosity
- # level will be that high, and the less likely
- # the string will print to the VU Notebook.
- # If v_level is zero or less, or if the global
- # verbosity level is zero, return false.
- # Returns: true if printing should occur, false if not
- # History:
- # ??? ??? Created
- # 02/22/94 SBR Changed v_level = 0 to v_level <= 0
- #########################################################################
- task R_BeVerbose(v_level:=5)
- begin
- global r_verbosity;
- if isUndefined(r_verbosity)
- r_verbosity := 1;
- if r_verbosity = 0 or v_level <= 0
- return false;
- if r_verbosity < v_level
- return false;
- else return true;
- end;
-
- #########################################################################
- # task _takeScreenShot(v_level)
- # Description: Take a screen shot without using VUAid.Lib. Used by RResult.
- # Parameters: v_level: verbosity of log output
- # Returns: true if printing should occur, false if not
- # History:
- # 5/15/92 Jason Marsh Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task _takeScreenShot(v_level := 2)
- begin
- _PressKey({ shiftKey, commandKey}); #Screen shot fKey
- _Type({'3'});
- _ReleaseKey({ shiftKey, commandKey});
- wait(10); #Screen Shots can be slow
-
- timeStamp := time_str(time_list());
- result := VUAid2("FindFolder", "boot");
- if result[1] = 0
- begin
- VUAid2("Rename", result[2] + ":Picture 1", result[2] + ":ScreenShot@" + timeStamp);
- RAddResult("screenShot taken and named: ScreenShot@{timeStamp}");
- end;
- else
- RAddResult("screenShot taken but not renamed properly!");
- end;
-
- #########################################################################
- ######### String manipulation tasks #########
- #########################################################################
-
- #########################################################################
- # task midstr(str, pos, len)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task returns a string from the middle of the
- # given string. A pos of 1 refers to the first character.
- # It returns the empty string if pos is outside str.
- # Parameters: str: String to examine
- # pos: Position of subString
- # len: Length of subString
- # Returns: subString
- # Examples: midstr("abcde", 3, 999); #returns "cde"
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task midstr(str, pos, len)
- begin
- save_trace := trace(false);
- lstr := card str;
- mid := "";
- if pos = 1 and len >= lstr
- mid := str;
- else if (pos > 0 and pos <= lstr)
- begin
- limit := pos + len - 1;
- if limit > lstr
- limit := lstr;
- for i := pos to limit
- mid := mid + str[i];
- end;
- trace(save_trace);
- return mid;
- end;
-
-
- #########################################################################
- # task substr(bigstr, littlestr)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task returns the leftmost position at which the
- # substring {littlestr} matches the string {bigstr}, or
- # 0 if there is no match.
- # Parameters: bigstr: String to examine
- # littlestr: string to match
- # Returns: subString
- # Examples: substr("abcdbc", "bc"); #returns 2
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task substr(bigstr, littlestr)
- begin
- save_trace := trace(false);
- if not (bigstr ~= /≈{littlestr}≈/)
- begin
- trace(save_trace); # Modified here to restore trace setting
- return 0;
- end;
-
- blen := card bigstr;
- llen := card littlestr;
-
- if (blen < llen) # littlestr larger than bigstr
- begin
- trace(save_trace); # Modified here to restore trace setting
- return 0;
- end;
-
- for bpos := 0 to (blen - llen)
- begin
- gotit := true;
- for lpos := 1 to llen
- begin
- if littlestr[lpos] <> bigstr[lpos + bpos]
- begin
- gotit := false;
- lpos := llen;
- end;
- end;
- if gotit
- begin
- trace(save_trace); # Modified here to restore trace setting
- return (bpos + 1);
- end;
- end;
-
- trace(save_trace);
- return 0;
- end;
-
- #########################################################################
- # task list_to_str(theList, delimiter)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task returns a usable string from a list. Delimiter
- # specifies the separator. This task will work only on
- # lists of numbers or strings, not lists of lists,
- # descriptors, etc.
- # Parameters: theList: List to convert
- # delimiter: String to append between list items
- # Returns: resulting string
- # Examples: list_to_str({"a", "b", "c"}, " "); #returns "a b c"
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- # 12/03/93 SBR Fixed bug: theList was named MyList in some places
- # 12/03/93 SBR Fixed bug: list is now 'list'
- #########################################################################
- task list_to_str(theList := {}, delimiter := " ")
- begin
- if typeOf(theList) <> 'list' or card theList < 1
- return("");
- temp:= theList[1];
- result := "{temp}";
- for i := 2 to card theList
- begin
- temp := theList[i];
- result := result + delimiter + "{temp}";
- end;
- return result;
- end;
-
-
- #########################################################################
- # task str_to_list(str, delimiter)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task returns a usable string from a list. Delimiter
- # specifies the separator. This task will work only on
- # lists of numbers or strings, not lists of lists,
- # descriptors, etc.
- # Parameters: str: String to parse
- # delimiter: String that delimits items
- # Returns: resulting list
- # Examples: str_to_list({"a,b,c"}, ","); #returns ("a","b","c"}
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task str_to_list(str, delimiter := " ")
- begin
- MyList := {};
- done := false;
- while not done
- begin
- Space:= substr(str, delimiter);
- if space = 0
- begin
- MyList := MyList + {StrToNum(str)};
- done := true;
- end;
- else begin
- MyList := MyList + {StrToNum(midstr(str, 1, Space -1))};
- str := midstr(str, Space + 1, 999);
- end;
- end;
- return MyList;
- end;
-
-
-
- ##############################################################################
- ######### NEW INTERVAL TIMING TASKS ##########
- ######### These two tasks are specifically designed for routines that need to
- ######### do some activity for a limited amount of time, and periodically
- ######### check if the time limit has passed. They are optimized to be as
- ######### fast as possible, instead of doing generic "timer math". The
- ######### maximum interval allowed is slightly less than one day.
- #########
- ######### To initialize the timer, call get_end_time(), giving it the interval
- ######### between now until the time limit. It will return a list containing
- ######### the end time. This structure is similar to a time list, but it has
- ######### been optimized for quickly checking intervals of less than a minute.
- #########
- ######### To check if the time limit has passed, call timed_out(), giving it
- ######### the list from get_end_time(). It will return true if the time limit
- ######### has passed, or false if there is still time left.
- ##############################################################################
-
- #########################################################################
- # task timed_out(endTime)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Checks to see if the current time is after the specified
- # endTime. This is for intervals less than a day and is
- # optimized for speed. The basic idea is, do all the math
- # once at the beginning. Then rather than carry around an
- # interval, carry the actual time of expiration. To check
- # if the time has expired, just do a compare, and almost
- # no calculations. Use the get_end_time() task to calculate
- # the proper endTime given the start time and an interval.
- # This task is designed for speed and does not log status.
- # Parameters: endTime: {ss,mins,dd,mm,yyyy} where all fields are equal
- # to time descriptor traits except for mins, in
- # the form 0 <= mins <= 1338. There is no hours field,
- # because the minutes field can hold an entire day.
- # Returns: false if current time is less than endTime
- # true if current time is greater than endTime,
- # i.e. the process has timed out
- # Assumptions: For any interval you are checking, there is only one
- # crossing of 12 midnight, i.e. interval < 24 hrs.
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 05/22/94 SBR Created
- # 02/20/95 SBR Added trace hiding
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task timed_out(endTime := {0,0,0,0,0})
- begin
- saveTrace := trace(false);
-
- try begin
- try
- match [time y:?curYear m:?curMonth d:?curDay h:?curMinute s:?curSecond];
- catch theError
- ExceptionDispatcher(theError,,{"timed_out() match", {endTime}});
-
- curMinute := (curMinute/100) * 60 + (curMinute mod 100); #1438 min = 23:58:00
- endSecond := endTime[1];
- endMinute := endTime[2];
-
- if curMinute = endMinute # only occurs if elapsed <= 59 seconds
- begin # i.e. can only occur on the same day
- if curSecond < endSecond
- throw false;
- else throw true;
- end;
-
- # After this point all we need is one clue to determine if we are before
- # or after the endTime.
-
- endDay := endTime[3];
- if curDay = endDay
- begin
- if curMinute < endMinute
- throw false;
- else throw true;
- end;
-
- endMonth := endTime[4];
- if curMonth = endMonth
- begin
- if curDay < endDay
- throw false;
- else throw true;
- end;
-
- endYear := endTime[5];
- if curYear = endYear
- begin
- if curMonth < endMonth
- throw false;
- else throw true;
- end;
-
- if curYear < endYear
- throw false;
- else throw true;
- end;
- catch theReturnValue
- begin
- if typeOf(theReturnValue) = 'symbol' # we expect a Boolean type
- begin
- trace(saveTrace);
- return theReturnValue;
- end;
- else
- begin
- RIncomplete( "timed_out: caught unexpected error: {theReturnValue}; throwing",1);
- trace(saveTrace);
- throw theReturnValue;
- end;
- end;
- end;
-
- ##############################################################################
- # task get_end_time(interval)
- ##############################################################################
- # Description: Use the get_end_time() task to calculate the proper
- # endTime. The start time is whenever the task is called.
- # This task is designed for speed and does not log status.
- # Parameters:
- # interval: list: {ss,mins} where
- # 0 <= ss <= 59
- # 0 <= mins <= 1338 1338 = 24 hrs - 2 min
- # or: integer: ss where
- # 0 <= ss <= 32706 32706 = 32767 - 61 = {7,544}
- # sum of ss and curSecond must be < VU 2.0.1 max integer
- # CAUTION: The total interval must be < 23 hrs, 59 min,
- # because the optimizations depend on it.
- # Returns: {ss,mins,dd,mm,yyyy} where all fields are equal
- # to time descriptor traits except for mins, in
- # the form 0 <= mins <= 1338. There is no hours field,
- # because the mins field can hold an entire day.
- # Assumptions: For any interval you are checking, there is only one
- # crossing of midnight. This is always true using legal
- # values for the interval.
- #
- # Date Initials Change
- # 05/22/94 SBR Created
- # 06/07/94 SBR Added 'ifs' for carries; allow integer interval
- # 06/29/94 SBR Return a value for next larger item even if no carry
- # because timed_out needs it. Others remain undefined.
- # 07/06/94 SBR Decreased max ss from 80339 to 32706 to avoid VU 2.0.1
- # integer overflow when we add intervalSec to curSec.
- # 02/20/95 SBR Added trace hiding
- # 09/27/96 BRL/MSO Added SPEC exception handling
- ##############################################################################
- task get_end_time(interval := {10,0})
- begin
- saveTrace := trace(false);
-
- try
- match [time y:?curYear m:?curMonth d:?curDay h:?curMinute s:?curSecond];
- catch theError
- ExceptionDispatcher(theError,,{"get_end_time() match", {interval}});
-
- curMinute := (curMinute/100) * 60 + (curMinute mod 100);
-
- if typeOf(interval) = 'list'
- begin
- intervalSec := interval[1];
- intervalMin := interval[2];
- end;
- else begin #typeOf(interval) = 'integer'
- intervalSec := interval;
- intervalMin := 0;
- end;
-
- endSecond := curSecond + intervalSec;
- carry := 0;
- if endSecond >= 60
- begin
- carry := endSecond / 60;
- endSecond := endSecond mod 60;
- end;
-
- if carry
- begin # carry into next minute
- endMinute := curMinute + intervalMin + carry;
- carry := 0;
- if endMinute >= 1440
- begin
- carry := 1;
- endMinute := endMinute - 1440;
- end;
-
- if carry
- begin # carry into next day
- endDay := curDay + carry;
- carry := 0;
-
- len := {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}[curMonth];
- if (curMonth = 2) and ((curYear mod 4) = 0) len := len + 1;
-
- if endDay > len
- begin
- carry := 1;
- endDay := endDay - len;
- end;
-
- if carry
- begin # carry into next month
- endMonth := curMonth + carry;
- carry := 0;
- if endMonth > 12
- begin
- carry := 1;
- endMonth := endMonth - 12;
- end;
-
- if carry # carry into next year
- endYear := endYear + carry;
- else
- endYear := curYear; # 06/29 SBR: year value if no carry
- end;
- else
- endMonth := curMonth; # 06/29 SBR: month value if no carry
- end;
- else
- endDay := curDay; # 06/29 SBR: day value if no carry
- end;
- else
- endMinute := curMinute; # 06/29 SBR: minute value if no carry
-
- trace(saveTrace);
-
- return {endSecond, endMinute, endDay, endMonth, endYear};
- end;
-
-
-
- #########################################################################
- ######### TIME TASKS #########
- ######### These tasks manipulate 'time' data structures, #########
- ######### which are lists consisting of: #########
- ######### {sec, min, hour, day, month, year, sign} #########
- ######### The sign may be +1 or -1. #########
- #########################################################################
-
- #########################################################################
- # task timer(func)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task implements a timer.
- # Parameters: func:
- # 'reset': Reset the timer to zero.
- # 'read': Read the current elapsed time since
- # 'reset' was called.
- # Returns: resulting time list if func = 'read'
- # Examples: timer('reset);
- # elapsedTime := timer('read');
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task timer(func := 'null')
- begin
- global timer_start;
-
- if (func = 'reset')
- timer_start := _Match([time]);
- else if (func = 'read') return time_sub(_Match([time]), timer_start);
- end;
-
-
- #########################################################################
- # task time_list(when)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task converts a time descriptor to our 'time' format.
- # Parameters: when: time descriptor
- # Returns: resulting time list
- # Examples: now:= time_list();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- # 8/30/96 Marie Added _Match
- #########################################################################
- task time_list(when := _Match([time]))
- begin
- return {when.s, (when.h mod 100), (when.h / 100), when.d, when.m, when.y, 1};
- end;
-
-
- #########################################################################
- # task time_cmp(stop_time, start_time)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task compares two times.
- # Parameters: stop_time: time descriptor or time list
- # start_time: time descriptor or time list
- # Returns: +1 if the stop_time is greater than the start_time
- # 0 if they are equal
- # -1 if the stop_time is less than the start_time.
- # Examples: if (time_cmp(start_time, now)) timewarp();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task time_cmp(stop_time, start_time)
- begin
- if typeOf(stop_time) = 'descriptor'
- return time_cmp(time_list(stop_time), start_time);
- if typeOf(start_time) = 'descriptor'
- return time_cmp(stop_time, time_list(start_time));
-
- for i := 7 to 1 step -1
- begin
- if stop_time[i] > start_time[i]
- return 1;
- else if stop_time[i] < start_time[i]
- return -1;
- end;
- return 0;
- end;
-
-
- #########################################################################
- # task time_neg(t)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Returns the negative of a time list.
- # Parameters: t: time list
- # Returns: negative of the time list
- # Examples: time_add(then, time_neg(now));
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task time_neg(t)
- begin
- if typeOf(t) = 'descriptor'
- return time_neg(time_list(t));
- sign := -1 * t[7];
- return replace(sign, 7, t);
- end;
-
- #########################################################################
- # task time_add(a, b)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task computes the sum of two times.
- # Parameters: a: time descriptor or time list
- # b: time descriptor or time list
- # Returns: resulting time list
- # Examples: time_add(then, now);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task time_add(a, b)
- begin
- if typeOf(a) = 'descriptor'
- return time_add(time_list(a), b);
- if typeOf(b) = 'descriptor'
- return time_add(a, time_list(b));
-
- (*Handle signs*)
-
- if a[7] > 0
- begin
- if a[7] < 0 # a>0, b<0
- return time_sub(a, time_neg(b));
- end;
- else begin
- if b[7] > 0 # a<0, b>0
- return time_sub(b, time_neg(a));
- else # a<0, b<0
- return time_neg(time_add(time_neg(a), time_neg(b)));
- end;
-
- (*If we've gotten to here then both times are positive*)
-
- save_trace := trace(false);
- sec := a[1] + b[1];
- carry := 0;
- if sec > 60
- begin
- carry := 1;
- sec := sec - 60;
- end;
-
- min := a[2] + b[2] + carry;
- carry := 0;
- if min > 60
- begin
- carry := 1;
- min := min - 60;
- end;
-
- hour := a[3] + b[3] + carry;
- carry := 0;
- if hour > 24
- begin
- carry := 1;
- hour := hour - 24;
- end;
-
- day := a[4] + b[4] + carry;
- carry := 0;
-
- len := {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}[a[5]];
- if (a[5] = 2) and ((a[6] mod 4) = 0) len := len + 1;
-
- if day > len
- begin
- carry := 1;
- day := day - len;
- end;
-
- month := a[5] + b[5] + carry;
- carry := 0;
- if month > 12
- begin
- carry := 1;
- month := month - 12;
- end;
-
- year := a[6] + b[6] + carry;
- trace(save_trace);
-
- return {sec, min, hour, day, month, year, 1};
- end;
-
- #########################################################################
- # task time_sub(stop_time, start_time)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task computes the difference of two times.
- # Parameters: stop_time: time descriptor or time list
- # start_time: time descriptor or time list
- # Returns: resulting time list
- # Examples: time_sub(then, now);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task time_sub(stop_time, start_time)
- begin
- if typeOf(stop_time) = 'descriptor'
- return time_sub(time_list(stop_time), start_time);
- if typeOf(start_time) = 'descriptor'
- return time_sub(stop_time, time_list(start_time));
-
- (*Handle signs*)
-
- save_trace := trace(false);
- if stop_time[7] > 0 begin
- if start_time[7] < 0 # a>0, b<0
- return time_add(stop_time, time_neg(start_time));
- end;
- else begin
- if start_time[7] > 0 # a<0, b>0
- return time_neg(time_add(time_neg(stop_time), start_time));
- else # a<0, b<0
- return time_sub(time_neg(start_time), time_neg(stop_time));
- end;
-
- (*If we've gotten to here then both times are positive*)
-
- if time_cmp(stop_time, start_time) = -1
- return time_neg(time_sub(start_time, stop_time));
-
- start_s := start_time[1];
- start_min := start_time[2];
- start_h := start_time[3];
- start_d := start_time[4];
- start_m := start_time[5];
- start_y := start_time[6];
-
- stop_s := stop_time[1];
- stop_min := stop_time[2];
- stop_h := stop_time[3];
- stop_d := stop_time[4];
- stop_m := stop_time[5];
- stop_y := stop_time[6];
-
- if stop_s < start_s
- begin
- stop_s := stop_s + 60;
- stop_min := stop_min - 1;
- end;
- stop_s := stop_s - start_s;
-
- if stop_min < start_min
- begin
- stop_min := stop_min + 60;
- stop_h := stop_h - 1;
- end;
- stop_min := stop_min - start_min;
-
- if stop_h < start_h
- begin
- stop_h := stop_h + 24;
- stop_d := stop_d - 1;
- end;
- stop_h := stop_h - start_h;
-
- if stop_d < start_d
- begin
- month_index := stop_m - 1;
- if (month_index = 0)
- month_index := 12;
- stop_d := stop_d + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}[month_index];
- if (month_index = 2) and ((stop_y mod 4) = 0)
- stop_d := stop_d + 1;
- stop_m := stop_m - 1;
- end;
- stop_d := stop_d - start_d;
-
- if stop_m < start_m
- begin
- stop_m := stop_m + 12;
- stop_y := stop_y - 1;
- end;
- stop_m := stop_m - start_m;
-
- stop_y := stop_y - start_y;
- trace(save_trace);
- return {stop_s, stop_min, stop_h, stop_d, stop_m, stop_y, 1};
- end;
-
- #########################################################################
- # task time_str(t, format)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: This task returns a string of the form "{hour}:{min}:{sec}",
- # with numbers zero-padded on the left to two digits.
- # Parameters: t: time descriptor or time list
- # format: 'm' Give the minutes & seconds, "{min}:{sec}".
- # This will return strings with > 60 minutes,
- # if the hours are nonzero (e.g., "81:04").
- # 'h' Full format -- give the hours, minutes, & seconds.
- # Returns: resulting string
- # Examples: println time_sub(now, 'h');
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # ??? ??? Created
- #########################################################################
- task time_str(t, format := 'h')
- begin
- if typeOf(t) = 'descriptor'
- return time_str(time_list(t));
-
- save_trace := trace(false);
- s := t[1];
- m := t[2];
- h := t[3];
-
- str := "";
- if format = 'h'
- begin
- if h < 10 str := str + "0";
- str := str + "{h}.";
- end;
- else m := m + 60 * h;
-
- if m < 10
- str := str + "0";
- str := str + "{m}.";
- if s < 10
- str := str + "0";
- str := str + "{s}";
- trace(save_trace);
- return str;
- end;
-
-
- #########################################################################
- # task GetCheckSums(command, params)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Calls VUAid 2.0 to obtain checksums for all available
- # bit depths.
- # Parameters: command: VUAid 2.0 service to request
- # params: List of parameters to send to VUAid 2.0
- # Returns: Standard checksum list
- # Examples: println GetCheckSums("CompareWindowRect", {10,10,30,30})
- # Assumptions: Does not require VUAid.lib
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 4/22/92 Jonathan Marsh Original GetCheckSumList
- #########################################################################
- task GetCheckSums(command:="CompareWindow", params := {})
- begin
- checkSums:= {};
- oldDepth := VUAid2("GetDepth")[2];
- oldGrays := VUAid2("GetGray")[2];
-
- VUAid2("SetGray", 0); #Get color checksums
- if VUAid2("GetGray")[2] = 0
- begin
- for each bitdepth in {1, 2, 4, 8, 16, 32}
- begin
- VUAid2("SetDepth", bitdepth);
- if VUAid2("GetDepth")[2] = bitDepth
- if params = {}
- checkSums:= checkSums + {VUAid2(command)[2]};
- else checkSums:= checkSums + {VUAid2(command, params[1], params[2], params[3], params[4])[2]};
- else checkSums := checkSums + {'xxx'};
- end;
- end; #getDepth = 0
- else
- checkSums := {'xxx','xxx','xxx','xxx','xxx','xxx'};
-
- VUAid2("SetGray", 1); #Get gray checksums
- if VUAid2("GetGray")[2] = 1
- begin
- for each bitdepth in {2, 4, 8}
- begin
- VUAid2("SetDepth", bitdepth);
- if VUAid2("GetDepth")[2] = bitDepth
- if params = {}
- checkSums:= checkSums + {VUAid2(command)[2]};
- else checkSums:= checkSums + {VUAid2(command, params[1], params[2], params[3], params[4])[2]};
- else checkSums := checkSums + {'xxx'};
- end;
- end; #getDepth = 0
- else
- checkSums := {'xxx','xxx','xxx','xxx','xxx','xxx'};
-
- if checkSums[2] = checkSums[7] and checkSums[3] = checkSums[8] and checkSums[4] = checkSums[9]
- begin
- checkSums := remove(9, checkSums);
- checkSums := remove(8, checkSums);
- checkSums := remove(7, checkSums);
- end;
-
- VUAid2("SetGray", oldGrays);
- VUAid2("SetDepth", oldDepth);
- return checkSums;
- end;
-
- #########################################################################
- # task ComputerAidedSE(CAidedSE)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: These routines are run from an rResult statement when
- # Computer Aided Scripting Environment (CAidedSE) is enabled.
- # They print out an entire testN, with a completed checksumList,
- # instead of the normal error report, which can then be
- # pasted directly into the script. This should be used
- # after script development is complete to generate the
- # final checksumList needed for successful execution on
- # all bit-depths, color and grays. In order to fully
- # utilize this tool, it is suggested that the script be run
- # on a color machine which is 16-bit and 24-bit capable.
- # To turn on this function, call rSetCAidedSE(true).
- # Parameters: CAidedSE: a list of information needed of format:
- # {testN, {CheckSumLocation, VUAidStringToExecute}
- # [,{CheckSumLocation, VUAidStringToExecute}...]};
- # testN: the entire original test,
- # checkSumLocation: the item which should be replaced by a checksumList, and
- # VUAidStringToExecute: the string to send to VUAid.
- # NOTE: since a testN can conceivably incorporate multiple checksumlists,
- # these can created by a third (or more) item shown above.
- # If only a single VUAidCommand should be executed to return a single
- # expected item instead of a list, then put a negative if front of the
- # checkSumLocation
- # Returns: Nothing
- # Examples: ComputerAidedSE(testN);
- # Assumptions: That VUAid is correctly installed. This does no VUAid error checking!
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 06/09/92 Jason Marsh Creation of ComputerAidedSE
- # 4/19/94 Alan Winslow Fixed VUAid2 call for a single item
- # 4/29/94 Alan Winslow Added ability to handle case where VUAidString does not require
- # a WindowRect (ex: "Balloon", for checksumming help balloons)
- #########################################################################
- task ComputerAidedSE(CAidedSE)
- begin
- #CAidedSE := {testN, {CheckSumLocation, VUAidCommandString, VUAidParameterList}
- # [,{CheckSumLocation, VUAidCommandString, VUAidParameterList}...]};
-
- testN := CAidedSE[1];
- for i := 2 to card CAidedSE
- begin
- CheckSumLoc := CAidedSE[i][1];
- VUAidString := CAidedSE[i][2];
- VUAidParams := CAidedSE[i][3];
- VUP := VUAidParams; # AMW Used below to shorten calling sequence
- if CheckSumLoc > 0 #Get a checkSum List
- begin
- checkSumList := GetCheckSums(VUAidString, VUAidParams);
- testN := replace( checkSumList, CheckSumLoc, testN);
- end;
- else begin #just a single item
- CheckSumLoc := CheckSumLoc * -1;
- if VUAidParams = {} or VUAidParams = undefined
- temp := VUAid2(VUAidString)[2]; # AMW Example: "Balloon"
- else temp := VUAid2(VUAidString, VUP[1], VUP[2], VUP[3], VUP[4])[2];
- testN := replace( temp, CheckSumLoc, testN);
- end;
- end;
-
- println testN, ",";
- global gAddResult := {}; #Clear the Add result queue
- return true;
- end;
-
- #########################################################################
- # task rSetCAidedSE(state)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Turn on or off ComputerAidedSE feature.
- # Parameters: state: turn ComputerAidedSE on (true) or off (false)
- # Returns: Nothing
- # Examples: rSetCAidedSE(true);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 06/09/92 Jason Marsh Creation of ComputerAidedSE
- #########################################################################
- task rSetCAidedSE(state := true)
- begin
- global gCAidedSEEnabled := state;
- end;
-